﻿@model BcdVolumeDirectoryViewModel
@{
    Layout = null;
    ViewBag.Title = "未归档文件添加";
}

<script src="/Scripts/jQuery/jquery.validate.min.js" type="text/javascript"></script>
<script src="/Scripts/jQuery/jquery.validate.unobtrusive.min.js" type="text/javascript"></script>
@{Html.EnableClientValidation();}
@using (Html.BeginForm("AddPost", "VolumeList", null, FormMethod.Post, new { id = "form_volume", onsubmit = "return validateCallback(this,volumeAdd);", @class = "pageForm required-validate" }))
{
    <div class="pageFormContent sortDrag" layouth="60">
        <input type="hidden" id="input_cont" value="0" />
        @Html.TextBoxFor(model => model.TheBcdVolumedirectoryInfo.Vd_ID, new { @type = "hidden" })
        @Html.TextBoxFor(model => model.TheBcdVolumedirectoryInfo.Pft_ID, new { @type = "hidden" })
        <table class="tab01 tabNo" width="95%;">
            <tr>
                <td class="td1" style="width: 30%;">文件编号：</td>
                <td>
                    @Html.TextBoxFor(model => model.TheBcdVolumedirectoryInfo.Vd_Code, new { @class = "input02" })
                </td>
            </tr>
            <tr>
                <td class="td1">责任者：</td>
                <td>
                    @Html.TextBoxFor(model => model.TheBcdVolumedirectoryInfo.Vd_Duty, new { @class = "input02" })
                    @Html.ValidationMessageFor(model => model.TheBcdVolumedirectoryInfo.Vd_Duty)
                </td>
            </tr>
            <tr>
                <td class="td1">文件材料题名：</td>
                <td>
                    @Html.TextAreaFor(model => model.TheBcdVolumedirectoryInfo.Vd_Name, new { cols = "3", @class = "input05" })
                    @Html.ValidationMessageFor(model => model.TheBcdVolumedirectoryInfo.Vd_Name)
                </td>
            </tr>
            <tr>
                <td class="td1">日期：</td>
                <td>
                    @Html.TextBoxFor(model => model.TheBcdVolumedirectoryInfo.Vd_Date, new { @class = "date input02", @readonly = "readonly", format = "yyyy-MM-dd" })
                    @Html.ValidationMessageFor(model => model.TheBcdVolumedirectoryInfo.Vd_Date)
                </td>
            </tr>
            <tr>
                <td class="td1">总页数：</td>
                <td>
                    @Html.TextBoxFor(model => model.TheBcdVolumedirectoryInfo.Vd_PageNumb, new { @class = "input02 digits" })
                    @Html.ValidationMessageFor(model => model.TheBcdVolumedirectoryInfo.Vd_PageNumb)
                </td>
            </tr>
            <tr>
                <td class="td1">卷内序号：</td>
                <td>
                    @Html.TextBoxFor(model => model.TheBcdVolumedirectoryInfo.Vd_Order, new { @class = "input02" })
                </td>
            </tr>
            <tr>
                <td class="td1">卷内页数：</td>
                <td>
                    @Html.TextBoxFor(model => model.TheBcdVolumedirectoryInfo.Vd_Page, new { @class = "input02" })
                </td>
            </tr>
            <tr>
                <td class="td1">备注：</td>
                <td>
                    @Html.TextAreaFor(model => model.TheBcdVolumedirectoryInfo.Vd_Remark, new { cols = "3", @class = "input05" })
                </td>
            </tr>
            <tr>
                <td class="td1">附件：</td>
                <td id="td_ass">
                    <button type="button" onclick="VolumeFile_Add()">附件文件管理</button>
                </td>
            </tr>
        </table>
    </div>
    <div class="formBar">
        <ul>
            <li>
                <button type="button" class="btn btn-sm" onclick="contadd()">继续添加</button>
            </li>
            <li>
                <button type="button" class="btn btn-sm" onclick="aolumeAddPost()">保存</button>
            </li>
            <li>
                <button type="button" class="close btn btn-default btn-sm">取消</button>
            </li>
        </ul>
    </div>
}

<div id="dialog_file_add">
    <iframe id="myIframe_add" src="" frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="no"
        style="height: 650px; width: 1150px;"></iframe>
</div>
<script>
    var dialog_file_path = '@ViewBag.FilePath';
    $("#dialog_file_add").dialog({
        title: "附件管理",
        autoOpen: false,
        modal: true,
        width: 1200,
        height: 710,
        open: function (ev, ui) {
            $('#myIframe_add').attr('src', 'CompletionMaterials/FileManager/Index?filePath=' + encodeURI(dialog_file_path));
        }
    });
    function VolumeFile_Add() {
        $('#dialog_file_add').dialog('open');
    }

    function volumeAdd(json) {
        DWZ.ajaxDone(json);
        if (json.statusCode == DWZ.statusCode.ok) {
            refre_jgzl_cllx_index(json);
            $("form[name='pagerForm_volume']", navTab.getCurrentPanel()).submit();
            if ($("#input_cont").val() == "0") {
                //添加
                $.pdialog.closeCurrent();
            }
            else {
                //继续添加
                $("#TheBcdVolumedirectoryInfo_Vd_ID").val(json.vd_id);
                dialog_file_path = json.path;
                //$('#myIframe_add').attr('src', 'CompletionMaterials/FileManager/Index?filePath=' + encodeURI());

                var unit = $("#TheBcdVolumedirectoryInfo_Vd_Duty").val();
                var order = $("#TheBcdVolumedirectoryInfo_Vd_Order").val();
                $("#form_volume input[type=text]").val("");
                $("#TheBcdVolumedirectoryInfo_Vd_Duty").val(unit);
                if (order != "") {
                    order = parseInt(parseInt(order) + 1);
                    if (order < 10)
                        order = "0" + order;
                    $("#TheBcdVolumedirectoryInfo_Vd_Order").val(order);
                }
                $("#form_volume textarea").val("");
                $("#input_cont").val("0");
            }
        }
    }
    //添加
    function aolumeAddPost() {
        $("#input_cont").val("0");
        $("#form_volume").submit();
    }
    //继续添加
    function contadd() {
        $("#input_cont").val("1");
        $("#form_volume").submit();
    }
</script>
